package org.example.common.config;

import org.example.common.valid.RequestWrapperFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FilterConfig {


    @Bean
    public FilterRegistrationBean<RequestWrapperFilter> requestWrapperFilter() {
        FilterRegistrationBean<RequestWrapperFilter> registration = new FilterRegistrationBean<>();
        registration.setFilter(new RequestWrapperFilter());
        registration.setOrder(20); // 请求参数包装过滤器靠后优先级
        registration.addUrlPatterns("/*");
        return registration;
    }

//    @Bean
//    public FilterRegistrationBean<JwtAuthenticationFilter> jwtFilterRegistration() {
//        FilterRegistrationBean<JwtAuthenticationFilter> registration = new FilterRegistrationBean<>();
//        registration.setFilter(new JwtAuthenticationFilter());
//        registration.setOrder(Ordered.HIGHEST_PRECEDENCE + 10); // JWT认证过滤器次高优先级
//        registration.addUrlPatterns("/*");
//        return registration;
//    }
}
